package com.baizhi.controller;

import com.baizhi.service.UserService;
import com.baizhi.service2.UserService2;
import com.baizhi.util.ThreadPollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

@Controller
public class UserController {
    @Autowired
    private UserService us;
    @Autowired
    private UserService2 us2;

    @RequestMapping("fy")
    @ResponseBody
    public Map fy(int page, int rows) {

        return us.fy(page, rows);
    }

    @RequestMapping("dj")
    @ResponseBody
    public Map dj(int[] id) {
        System.out.println(id + "---------------------------");
        System.out.println(id + "---------------------------");
        System.out.println(id + "---------------------------");
        return us2.dj(id);
    }

    @RequestMapping("jd")
    @ResponseBody
    public Map jd(int[] id) {

        return us2.jd(id);
    }

    @RequestMapping("getSex")
    @ResponseBody
    public Map getSex() {
        Map map = new HashMap();
        int sex = us.getNan();
        int nv = us.getNv();
        map.put("nan", sex);
        map.put("nv", nv);
        return map;

     /*   Map map=new HashMap();

        //创建任务计数器 参数为设置任务数量
        CountDownLatch countDownLatch=new CountDownLatch(1);

        //使用线程池创建三个线程
        ThreadPollUtil.executor.submit(new Runnable() {
            @Override
            public void run() {
                //得到查询结果
                Map maps = us.getNv();
                map.put("sex", maps);
                //计数器减一
                countDownLatch.countDown();



            }


        });

            countDownLatch.await();
            return map;
    }*/
    }
}
